import Vue from 'vue'
import Router from 'vue-router'
import head from 'components/head'
import homepage from 'components/home'
import channel from 'components/channel'
import content from 'components/content/content'
import space from 'components/space/space'
import login from 'components/login/login'


Vue.use(Router)

const router = new Router({
  routes: [
    {
      path:'/',
     	redirect:"/index"//重定向,在home
    },
		{
			path:'/index',
			name:"home",
			component:homepage
		},
		{
			path:'/channel/:tid',
			name:"channel",
			component:channel,
		},
		{
			path:'/login',
			name:"login",
			component:login,
		},
		{
			path:'/space/',
			name:"space",
			component:space,
			meta:{
				requireAuth:true
			}
		}
  ]
})
//全局守卫
//router.beforeEach((to,from,next)=>{
//	if(to.matched.some(record=>record.meta.requireAuth)){
//		if(localStorage.getItem("isLogin")){
//			next()
//		}else{
//			next({
//				path:'/login',
//				query:{
//					redirect:to.fullPath
//				}
//			})
//		}
//	}else{
//		next()
//	}
////	console.log(to)
////	console.log(from)
//})
export default router 